<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateFilesTable extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('files', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->unsignedBigInteger('user_id',false)->default(0)->index()->comment('用户id');
            $table->boolean('is_admin')->default(false)->comment('是否管理员');
            $table->string('file_name')->comment('原文件名');
            $table->string('extension',20)->comment('文件扩展名');
            $table->string('path')->comment('文件路径');
            $table->unsignedInteger('size',false)->default(0)->comment('文件尺寸');
            $table->string('mime',60)->comment('文件mime类型');
            $table->boolean('is_image')->default(true)->comment('是否图片文件');
            $table->unsignedBigInteger('fileable_id',false)->default(0)->comment('morph id');
            $table->string('fileable_type',90)->nullable()->comment('morph type');
            $table->timestamps();
            $table->softDeletes();
            $table->engine="InnoDb";
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('files');
    }
}
